<?php
namespace app\api\controller;

use app\BaseController;
use app\service\CoupletService;
use think\facade\Request;
use think\facade\View;

class Couplet extends BaseController
{
    public function index()
    {
        return View::fetch('index');
    }

    public function identify()
    {
        $sentence1 = Request::param('sentence1');
        $sentence2 = Request::param('sentence2');

        try {
            $service = new CoupletService();
            $result = $service->identifyCouplet($sentence1, $sentence2);

            return json([
                'code' => 200,
                'data' => $result
            ]);
        } catch (\Exception $e) {
            return json([
                'code' => 500,
                'msg' => $e->getMessage()
            ]);
        }
    }
}